home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / commands / tty.c < prev    next >
C/C++ Source or Header  |  1990-07-23  |  443b  |  24 lines

  1. /* tty.c - Return tty name        Author: Freeman P. Pascal IV */
  2.  
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6.  
  7. int main(argc, argv)
  8. int argc;
  9. char *argv[];
  10. {
  11.   char *tty_name;
  12.  
  13.   tty_name = ttyname(0);
  14.   if ((argc == 2) && (!strcmp(argv[1], "-s")))
  15.      /* Do nothing - shhh! we're in silent mode */ ;
  16.   else
  17.     puts((tty_name != (char *) NULL) ? tty_name : "Not a tty");
  18.  
  19.   if (tty_name == (char *) NULL)
  20.     exit(1);
  21.   else
  22.     exit(0);
  23. }
  24.